package nowcoder.written_examination.wangyi;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/**
 * @author fance
 * @date 2018/7/22 20:02
 */
public class MainVII {
   /* public static void main(String[] args) {
        int[][] map = new int[1001][1001];
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int[] x = new int[n];
            int[] y = new int[n];
            for (int i = 0; i < n; i++) {
               x[i] = scanner.nextInt();
            }
            for (int i = 0; i < n; i++) {
               y[i] = scanner.nextInt();
            }
            for (int i = 0; i < n; i++) {
                map[x[i]][y[i]] = 1;
            }
            int minStep = 2000;
            for (int i = 1; i < 1001; i++) {
                for (int j = 1; j < 1001; j++) {
                    if (map[i][j] == 1) {
                        minStep = Math.min(minStep,i + j - 2);
                    }
                }
            }
            System.out.println(minStep);
        }
    }
}*/
/*    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
           String a = scanner.nextLine();
           String b = scanner.nextLine();
           int cnt = 0;
           String s1 = b + a;
           String s2 = a + b;
           if (isPalindrome(s1)) {
               cnt++;
           }if (isPalindrome(s2)) {
               cnt++;
           }
            for (int i = 1; i < a.length(); i++) {
                if (isPalindrome(a.substring(0,i) + b + a.substring(i))) {
                    cnt++;
                }
            }
            System.out.println(cnt);
        }
    }
    public static boolean isPalindrome(String s) {
        int st = 0,end = s.length() - 1;
        while (st < end) {
            if (s.charAt(st++) != s.charAt(end--)) {
                return false;
            }
        }
        return true;
    }
}*/
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            String[] a = new String[n];
            for (int i = 0; i < n; i++) {
                a[i] = scanner.next();
            }
            if (isDictSort(a) && isLenSort(a)) {
                System.out.println("both");
            } else if (isDictSort(a)) {
                System.out.println("lexicographically");
            } else if (isLenSort(a)) {
                System.out.println("lengths");
            } else {
                System.out.println("none");
            }
        }
    }
    public static boolean isDictSort(String[] a) {
        String[] newArr = a.clone();
        Arrays.sort(newArr);
        return Arrays.equals(a,newArr);
    }
    public static boolean isLenSort(String[] a) {
        String[] newArr = a.clone();
        Arrays.sort(newArr, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o1.length() - o2.length();
            }
        });
        return Arrays.equals(a,newArr);
    }
}
    /*public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[] dp = new int[40];
        dp[0] = 0;
        dp[1] = 1;
        for (int i = 2; i < 40; i++) {
            dp[i] = dp[i - 1] + dp[i - 2];
        }
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int minGap = Integer.MAX_VALUE;
            for (int i = 0; i < 40; i++) {
                minGap = Math.min(minGap,Math.abs(dp[i] - n));
            }
            System.out.println(minGap);
        }
    }
}*/
    /* 10
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = scanner.nextInt();
            }
            ArrayList<Integer> res = new ArrayList<>(n);
            for (int i = 0; i < n; i++) {
                res.add(a[i]);
            }
            for (int i = 0; i < n - 1; i++) {
                for (int j = i + 1; j < n; j++) {
                    add(a,i,j,res);
                }
            }
            int i = 1;
            while (res.contains(i++)) {
            }
            System.out.println(--i);
        }
    }
    public static void add(int[] a, int lo, int hi, ArrayList<Integer> res) {
        int sum = 0;
        for (int i = lo; i <= hi; i++) {
            sum += a[i];
        }
        res.add(sum);
    }


}*/
   /* 2
   public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = scanner.nextInt();
            }
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (isLucky(a,i,j)) {
                        cnt++;
                    }
                }
            }
            System.out.println(cnt);
        }
    }
    public static boolean isLucky(int[] a,int lo,int hi) {
        long sum = 0;
        long mul = 1;
        for (int i = lo; i <= hi; i++) {
            sum += a[i];
            mul *= a[i];
        }
        return sum > mul;
    }
}*/
